/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pt.ipleiria.plp.threads;

import javax.microedition.location.Coordinates;
import javax.microedition.location.LocationException;
import pt.ipleiria.plp.GPS;

public class ObtainPosition extends Thread {

    private GPS gps;
    private CallbackRetrievePos obj;

    public ObtainPosition(GPS gps, CallbackRetrievePos obj) {
        this.gps = gps;
        this.obj = obj;

    }

    public void run() {
        Coordinates cords = null;

        try {
            //if (gps == null) {
            this.gps = new GPS();
            //}
            cords = gps.getLocation();
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        } catch (LocationException ex) {
            ex.printStackTrace();
        }

        obj.returnCoordinates(cords);
    }
}
